package tools;

import java.awt.event.MouseEvent;

import application.CanvasView;

public class ObjectSelectorTool extends Tool
{
	protected CanvasView canvas;
	protected String [] shapeType;
	protected int [][] positions;
	protected int objectNumber;
	
	public ObjectSelectorTool(CanvasView c)
	{
		if (c != null)
			canvas = c;
		else
			throw new IllegalArgumentException();
		
		objectNumber = -5;
	}
	
	/**********Event Handlers******************/
	
	public void mouseReleased(MouseEvent e)
	{
		positions = canvas.getCanvasPositions();
		shapeType = canvas.getCanvasShapes();
			
		for(int count = 0; count < shapeType.length; count++)
		{
			if((e.getX() > positions[count][0]) && (e.getX() < positions[count][2]))
				if((e.getY() > positions[count][1]) && (e.getY() < positions[count][3]))
					objectNumber = count;
		}
		
		canvas.setCanvasObject(objectNumber, shapeType[objectNumber]);
		
	}
}
